const db = require('../config/db')
const {DataTypes} = require('sequelize');
const attributes = {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,            // 主键
        autoIncrement: true,// 自动递增
        comment: '评论id',
    },
    comment_content: {
        type: DataTypes.STRING,
        comment: '评论内容',
        allowNull: false
    },
    blog_text_id: {
        type: DataTypes.INTEGER,
        comment: '评论所对应的博客的id',
        allowNull: false
    },
    response_times: {
        type: DataTypes.INTEGER,
        comment: '回复次数',
        allowNull: true,
        defaultValue: 0
    },
    blog_user_id: {
        type: DataTypes.INTEGER,
        comment: '评论人ID',
        allowNull: false
    },
    parent_id: {
        type: DataTypes.INTEGER,
        comment: '指向父评论的id,如果不是对评论的回复,那么该值为null',
        allowNull: true
    },
}


const BlogComment = db.define('blog_comment', attributes)


BlogComment.sync({alter: true})

module.exports = BlogComment
